package com.itheima.app.interceptor;

import com.itheima.domain.db.User;

public class UserHolder {
    private static  ThreadLocal<User> local = new ThreadLocal<>();

    //存入线程对象
    public static void set(User user){
        local.set(user);
    }

    //获得线程对象
    public static User get(){
        return local.get();
    }

    //获得id
    public static Long getUserId(){
        return local.get().getId();
    }


    //删除对象
    public static void remove(){
        local.remove();
    }
}
